home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / commands / make / h.h < prev    next >
C/C++ Source or Header  |  1990-07-23  |  9KB  |  342 lines

  1. /*************************************************************************
  2.  *
  3.  *  m a k e :   h . h
  4.  *
  5.  *  include file for make
  6.  *========================================================================
  7.  * Edition history
  8.  *
  9.  *  #    Date                         Comments                       By
  10.  * --- -------- ---------------------------------------------------- ---
  11.  *   1    ??                                                         ??
  12.  *   2 23.08.89 LZ increased,N_EXISTS added,suffix as macro added    RAL
  13.  *   3 30.08.89 macro flags added, indention changed                 PSH,RAL
  14.  *   4 03.09.89 fixed LZ eliminated, struct str added,...            RAL
  15.  *   5 06.09.89 TABCHAR,M_MAKE added                                 RAL
  16.  *   6 09.09.89 tos support added, EXTERN,INIT,PARMS added           PHH,RAL
  17.  *   7 17.09.89 __STDC__ added, make1 decl. fixed , N_EXEC added     RAL
  18.  * ------------ Version 2.0 released ------------------------------- RAL
  19.  *
  20.  *************************************************************************/
  21.  
  22. #ifdef unix
  23. #include <sys/types.h>
  24. #include <sys/stat.h>
  25. #include <errno.h>
  26. #include <time.h>
  27. #include <utime.h>
  28. #endif
  29.  
  30. #ifdef eon
  31. #include <sys/stat.h>
  32. #include <sys/err.h>
  33. #endif
  34.  
  35. #ifdef os9
  36. #include <time.h>
  37. #include <os9.h>
  38. #include <modes.h>
  39. #include <direct.h>
  40. #include <errno.h>
  41. #endif
  42.  
  43. #ifdef tos
  44. struct DOSTIME {short time,date; };     /* time structure of TOS */
  45.  
  46. #ifdef LATTICE
  47. #include <error.h>
  48. #include <sys/types.h>
  49. #include <sys/stat.h>
  50. #include <osbind.h>
  51. #endif LATTICE
  52.  
  53. #ifdef TURBO
  54. #include <tos.h>
  55. #include <errno.h>
  56. #include <string.h>
  57. #endif TURBO
  58.  
  59. #endif tos
  60.  
  61. #include <ctype.h>
  62. #include <stdio.h>
  63.  
  64. #ifdef eon
  65. #define MNOENT ER_NOTF
  66. #else
  67. #define MNOENT ENOENT
  68. #endif
  69.  
  70. #ifndef uchar
  71. #ifdef os9
  72. #define uchar  char
  73. #define void   int
  74. #define fputc  putc
  75. #else
  76. #define uchar  unsigned char
  77. #endif
  78. #endif
  79.  
  80. #define bool   uchar
  81. #ifndef time_t
  82. #define time_t long
  83. #endif
  84. #define TRUE   (1)
  85. #define FALSE  (0)
  86. #define max(a,b) ((a)>(b)?(a):(b))
  87.  
  88. #ifdef unix
  89. #define DEFN1   "makefile"
  90. #define DEFN2   "Makefile"
  91. #endif
  92. #ifdef eon
  93. #define DEFN1   "makefile"
  94. #define DEFN2   "Makefile"
  95. #endif
  96. #ifdef tos
  97. #define DEFN1   "makefile."
  98. #define DEFN2   (char *)0
  99. #endif
  100. #ifdef os9
  101. #define DEFN1   "makefile"
  102. #define DEFN2   (char *)0
  103. #endif
  104.  
  105.  
  106. #ifdef os9
  107. #define TABCHAR ' '
  108. #else
  109. #define TABCHAR '\t'
  110. #endif
  111.  
  112. #define LZ1    (2048)        /*  Initial input/expand string size  */
  113. #define LZ2    (256)        /*  Initial input/expand string size  */
  114.  
  115.  
  116.  
  117. /*
  118.  *    A name.  This represents a file, either to be made, or existant
  119.  */
  120.  
  121. struct name
  122. {
  123.   struct name  *n_next;        /* Next in the list of names */
  124.   char         *n_name;        /* Called */
  125.   struct line  *n_line;        /* Dependencies */
  126.   time_t        n_time;        /* Modify time of this name */
  127.   uchar         n_flag;        /* Info about the name */
  128. };
  129.  
  130. #define N_MARK    0x01            /* For cycle check */
  131. #define N_DONE    0x02            /* Name looked at */
  132. #define N_TARG    0x04            /* Name is a target */
  133. #define N_PREC    0x08            /* Target is precious */
  134. #define N_DOUBLE  0x10            /* Double colon target */
  135. #define N_EXISTS  0x20            /* File exists */
  136. #define N_ERROR   0x40            /* Error occured */
  137. #define N_EXEC    0x80            /* Commands executed */
  138.  
  139. /*
  140.  *    Definition of a target line.
  141.  */
  142. struct    line
  143. {
  144.   struct line    *l_next;        /* Next line (for ::) */
  145.   struct depend  *l_dep;        /* Dependents for this line */
  146.   struct cmd     *l_cmd;        /* Commands for this line */
  147. };
  148.  
  149.  
  150. /*
  151.  *    List of dependents for a line
  152.  */
  153. struct    depend
  154. {
  155.   struct depend  *d_next;        /* Next dependent */
  156.   struct name    *d_name;        /* Name of dependent */
  157. };
  158.  
  159.  
  160. /*
  161.  *    Commands for a line
  162.  */
  163. struct    cmd
  164. {
  165.   struct cmd  *c_next;        /* Next command line */
  166.   char        *c_cmd;        /* Command line */
  167. };
  168.  
  169.  
  170. /*
  171.  *    Macro storage
  172.  */
  173. struct    macro
  174. {
  175.   struct macro *m_next;    /* Next variable */
  176.   char *m_name;        /* Called ... */
  177.   char *m_val;        /* Its value */
  178.   uchar m_flag;        /* Infinite loop check */
  179. };
  180.  
  181.  
  182. #define M_MARK        0x01    /* for infinite loop check */
  183. #define M_OVERRIDE    0x02    /* command-line override */
  184. #define M_MAKE        0x04    /* for MAKE macro */
  185.  
  186. /*
  187.  *    String
  188.  */
  189. struct    str
  190. {
  191.   char **ptr;        /* ptr to real ptr. to string */
  192.   int    len;        /* length of string */
  193.   int    pos;        /* position */
  194. };
  195.  
  196.  
  197. /* Declaration, definition & initialization of variables */
  198.  
  199. #ifndef EXTERN
  200. #define EXTERN extern
  201. #endif
  202.  
  203. #ifndef INIT
  204. #define INIT(x)
  205. #endif
  206.  
  207. extern int    errno;
  208. extern char **environ;
  209.  
  210. EXTERN char *myname;
  211. EXTERN bool  domake   INIT(TRUE);  /*  Go through the motions option  */
  212. EXTERN bool  ignore   INIT(FALSE); /*  Ignore exit status option      */
  213. EXTERN bool  conterr  INIT(FALSE); /*  continue on errors  */
  214. EXTERN bool  silent   INIT(FALSE); /*  Silent option  */
  215. EXTERN bool  print    INIT(FALSE); /*  Print debuging information  */
  216. EXTERN bool  rules    INIT(TRUE);  /*  Use inbuilt rules  */
  217. EXTERN bool  dotouch  INIT(FALSE); /*  Touch files instead of making  */
  218. EXTERN bool  quest    INIT(FALSE); /*  Question up-to-dateness of file  */
  219. EXTERN bool  useenv   INIT(FALSE); /*  Env. macro def. overwrite makefile def.*/
  220. EXTERN bool  dbginfo  INIT(FALSE); /*  Print lot of debugging information */
  221. EXTERN bool  ambigmac INIT(FALSE); /*  guess undef. ambiguous macros (*,<) */
  222. EXTERN struct name  *firstname;
  223. EXTERN char         *str1;
  224. EXTERN char         *str2;
  225. EXTERN struct str    str1s;
  226. EXTERN struct str    str2s;
  227. EXTERN struct name **suffparray; /* ptr. to array of ptrs. to name chains */
  228. EXTERN int           sizesuffarray INIT(20); /* size of suffarray */
  229. EXTERN int           maxsuffarray INIT(0);   /* last used entry in suffarray */
  230. EXTERN struct macro *macrohead;
  231. EXTERN bool          expmake; /* TRUE if $(MAKE) has been expanded */
  232. EXTERN int           lineno;
  233.  
  234. #ifdef tos
  235. #ifdef LATTICE
  236. EXTERN int _mneed INIT(60000);    /* VERY important for TOS with LATTICE C*/
  237. #endif LATTICE
  238. #endif tos
  239. #ifdef eon
  240. #define MEMSPACE  (16384)
  241. EXTERN unsigned  memspace = MEMSPACE;
  242. #endif
  243.  
  244. /* Defines function declarations for all functions */
  245.  
  246. #ifdef __STDC__
  247. #define CONST const
  248. #define LINT_ARGS
  249. #else
  250. #define CONST /* */
  251. #endif
  252.  
  253. #ifndef PARMS
  254. #ifdef  LINT_ARGS
  255. #define PARMS(x)   x
  256. #else
  257. #define PARMS(x)   ()
  258. #endif
  259. #endif
  260.  
  261. /*
  262. :.,$s/(PARMS\(.*\));/PARMS\1;/
  263. */
  264.  
  265. extern time_t  time PARMS(( time_t *));
  266. extern char   *ctime PARMS (( CONST time_t *));
  267. extern char   *getenv PARMS (( CONST char *));
  268. extern char   *fgets PARMS (( char *, int, FILE *));
  269. extern char   *strchr PARMS (( CONST char *, int));
  270. extern char   *strrchr PARMS (( CONST char *, int));
  271. #ifndef __STDC__
  272. extern char   *malloc PARMS (( unsigned));
  273. extern char   *realloc PARMS (( char *, unsigned)); /* OS9 ? */
  274. #else
  275. extern void   *malloc PARMS (( unsigned));
  276. extern void   *realloc PARMS (( void *, unsigned)); /* OS9 ? */
  277. #endif
  278.  
  279. /* main.c */
  280. void           main PARMS (( int, char **));
  281. void           setoption PARMS ((char));
  282. void           usage PARMS (());
  283. void           fatal PARMS (( char *, char *, int));
  284. /* check.c */
  285. void           prt PARMS (());
  286. void           check PARMS (( struct name *));
  287. void           circh PARMS (());
  288. void           precious PARMS (());
  289. /* input.c */
  290. void           init PARMS (());
  291. void           strrealloc PARMS (( struct str *));
  292. struct name   *newname  PARMS (( char *));
  293. struct name   *testname PARMS (( char *));
  294. struct depend *newdep PARMS (( struct name *, struct depend *));
  295. struct cmd    *newcmd PARMS (( char *, struct cmd *));
  296. void           newline PARMS (( struct name *, struct depend *, struct cmd *, int));
  297. void           input PARMS (( FILE *));
  298. /* macro.c */
  299. struct macro  *getmp PARMS (( char *));
  300. char          *getmacro PARMS (( char *));
  301. struct macro  *setmacro PARMS (( char *, char *));
  302. void           setDFmacro PARMS (( char *, char *));
  303. void           doexp PARMS (( struct str *, char *));
  304. void           expand PARMS (( struct str *));
  305. /* make.c */
  306. int            dosh PARMS (( char *, char *));
  307. void           docmds1 PARMS (( struct name *, struct line *));
  308. void           docmds PARMS (( struct name *));
  309. #ifdef tos
  310. int            Tosexec PARMS (( char *));
  311. time_t         mstonix PARMS (( struct DOSTIME *));
  312. #endif
  313. #ifdef os9
  314. void           getmdate PARMS (( int, struct sgtbuf *));
  315. time_t         cnvtime PARMS